home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / cl_7_bug.zip / BUG_1.ERR < prev    next >
Text File  |  1992-10-10  |  12KB  |  403 lines

  1. ;    Static Name Aliases
  2. ;
  3.     TITLE   bug_1.c
  4.     .8087
  5. INCLUDELIB      LLIBCE
  6. INCLUDELIB    OLDNAMES.LIB
  7. BUG_1_TEXT    SEGMENT  WORD PUBLIC 'CODE'
  8. BUG_1_TEXT    ENDS
  9. _DATA    SEGMENT  WORD PUBLIC 'DATA'
  10. _DATA    ENDS
  11. CONST    SEGMENT  WORD PUBLIC 'CONST'
  12. CONST    ENDS
  13. _BSS    SEGMENT  WORD PUBLIC 'BSS'
  14. _BSS    ENDS
  15. DGROUP    GROUP    CONST, _BSS, _DATA
  16.     ASSUME DS: DGROUP, SS: DGROUP
  17. EXTRN    __acrtused:ABS
  18. EXTRN    _printf:FAR
  19. _DATA      SEGMENT
  20. $SG262    DB    'ALLOC',  00H
  21. $SG263    DB    'ALLOCA',  00H
  22. $SG264    DB    'get_filename returns: %d, Should return 5',  0aH,  00H
  23. $SG275    DB    'A',  00H
  24. _DATA      ENDS
  25. BUG_1_TEXT      SEGMENT
  26.     ASSUME    CS: BUG_1_TEXT
  27.     PUBLIC    _main
  28. _main    PROC FAR
  29. ;|*** /*
  30. ;|***   Test if cl alias (?) bugg (there isn't any use of alias in this code)
  31. ;|***   or double loop variable bugg (two loops, if the first is removed it works)
  32. ;|***  */
  33. ;|*** 
  34. ;|*** #include <stdio.h>
  35. ;|*** 
  36. ;|*** typedef struct fileinfo        /* Struct returned from my_dir & my_stat */
  37. ;|*** {
  38. ;|***   char            *name;
  39. ;|*** } FILEINFO;
  40. ;|*** 
  41. ;|*** typedef struct my_dir        /* Struct returned from my_dir */
  42. ;|*** {
  43. ;|***   struct fileinfo    *dir_entry;
  44. ;|***   int number_off_files;
  45. ;|*** } MY_DIR;
  46. ;|*** 
  47. ;|*** void test_file(FILEINFO *test);
  48. ;|*** int get_filename(MY_DIR *dir_info);
  49. ;|*** 
  50. ;|***     /* This function breaks when compiling with
  51. ;|***        cl -Ox -AL.
  52. ;|***        Code breaks when using test_file() in loop 
  53. ;|***        (possibly alias test in cl) and the result
  54. ;|***        is a loop of garbage. (se bugg_1.cod)
  55. ;|***     */
  56. ;|*** 
  57. ;|*** int main(int argc,char *argv[])
  58. ;|*** {
  59. ; Line 30
  60.     *** 000000    55             push    bp
  61.     *** 000001    8b ec             mov    bp,sp
  62.     *** 000003    83 ec 24         sub    sp,36    ;0024H
  63. ;    argv = 8
  64. ;    dir_info = -24
  65. ;    fileinfo = -36
  66. ;    argc = 6
  67. ;|***   MY_DIR dir_info;
  68. ;|***   FILEINFO fileinfo[3];
  69. ;|*** 
  70. ;|***   fileinfo[0].name="ALLOC";
  71. ; Line 34
  72.     *** 000006    c7 46 dc 00 00         mov    WORD PTR [bp-36],OFFSET DGROUP:$SG262    ;fileinfo
  73.     *** 00000b    8c 5e de         mov    WORD PTR [bp-34],ds
  74. ;|***   fileinfo[1].name="ALLOCA";
  75. ; Line 35
  76.     *** 00000e    c7 46 e0 06 00         mov    WORD PTR [bp-32],OFFSET DGROUP:$SG263
  77.     *** 000013    8c 5e e2         mov    WORD PTR [bp-30],ds
  78. ;|***   dir_info.dir_entry=fileinfo;
  79. ; Line 36
  80.     *** 000016    8d 46 dc         lea    ax,WORD PTR [bp-36]    ;fileinfo
  81.     *** 000019    89 46 e8         mov    WORD PTR [bp-24],ax    ;dir_info
  82.     *** 00001c    8c 56 ea         mov    WORD PTR [bp-22],ss
  83. ;|***   dir_info.number_off_files=2;
  84. ; Line 37
  85.     *** 00001f    c7 46 ec 02 00         mov    WORD PTR [bp-20],2
  86. ;|***   
  87. ;|***   printf("get_filename returns: %d, Should return 5\n",
  88. ;|***        get_filename(&dir_info));
  89. ; Line 40
  90.     *** 000024    8d 46 e8         lea    ax,WORD PTR [bp-24]    ;dir_info
  91.     *** 000027    16             push    ss
  92.     *** 000028    50             push    ax
  93.     *** 000029    9a 00 00 00 00         call    FAR PTR _get_filename
  94.     *** 00002e    83 c4 04         add    sp,4
  95.     *** 000031    50             push    ax
  96.     *** 000032    b8 0d 00         mov    ax,OFFSET DGROUP:$SG264
  97.     *** 000035    1e             push    ds
  98.     *** 000036    50             push    ax
  99.     *** 000037    9a 00 00 00 00         call    FAR PTR _printf
  100. ;|***   return(0);
  101. ; Line 41
  102.     *** 00003c    33 c0             xor    ax,ax
  103. ;|*** }
  104. ; Line 42
  105.     *** 00003e    8b e5             mov    sp,bp
  106.     *** 000040    5d             pop    bp
  107.     *** 000041    cb             ret    
  108.  
  109. _main    ENDP
  110.     PUBLIC    _get_filename
  111. _get_filename    PROC FAR
  112. ;|*** 
  113. ;|***     /* Expand inputed filename */
  114. ;|*** 
  115. ;|*** int get_filename(MY_DIR *dir_info)
  116. ;|*** {
  117. ; Line 47
  118.     *** 000042    55             push    bp
  119.     *** 000043    8b ec             mov    bp,sp
  120.     *** 000045    83 ec 22         sub    sp,34    ;0022H
  121.     *** 000048    57             push    di
  122.     *** 000049    56             push    si
  123. ;    dir_info = 6
  124. ;    i = -18
  125. ;    k_length = -10
  126. ;    count = -20
  127. ;    part_name = -4
  128. ;    pos = -8
  129. ;    p_pos = -4
  130. ;    best_info = -16
  131. ;    j = -2
  132. ;|***   register int i;
  133. ;|***   int  k_length;
  134. ;|***   unsigned int count;
  135. ;|***   char *part_name,*pos,*p_pos;
  136. ;|***   struct fileinfo *best_info;
  137. ;|*** 
  138. ;|***   part_name="A";
  139. ; Line 54
  140.     *** 00004a    8c 5e fe         mov    WORD PTR [bp-2],ds    ;j
  141. ;|***   count=0; k_length= 1000;
  142. ; Line 55
  143.     *** 00004d    c7 46 ec 00 00         mov    WORD PTR [bp-20],0    ;count
  144.     *** 000052    c7 46 f6 e8 03         mov    WORD PTR [bp-10],1000    ;03e8H    ;k_length
  145. ;|*** 
  146. ;|***   for (i=0 ; i < dir_info->number_off_files ; i++)
  147. ; Line 57
  148.     *** 000057    c7 46 ee 00 00         mov    WORD PTR [bp-18],0    ;i
  149.     *** 00005c    c4 5e 06         les    bx,DWORD PTR [bp+6]    ;dir_info
  150.     *** 00005f    26 83 7f 04 00         cmp    WORD PTR es:[bx+4],0
  151.     *** 000064    7f 03             jg    $JCC100
  152.     *** 000066    e9 15 01         jmp    $FB278
  153.                     $JCC100:
  154.     *** 000069    c7 46 f4 00 00         mov    WORD PTR [bp-12],0
  155.                     $F276:
  156. ;|***     {
  157. ;|***     /* If next for-loop and test is removed the code works */
  158. ;|***       for (p_pos=part_name, pos=dir_info->dir_entry[i].name; *p_pos ;
  159. ;|***        pos++,p_pos++)
  160. ; Line 61
  161.     *** 00006e    26 c4 1f         les    bx,DWORD PTR es:[bx]
  162.     *** 000071    03 5e f4         add    bx,WORD PTR [bp-12]
  163.     *** 000074    89 5e e8         mov    WORD PTR [bp-24],bx
  164.     *** 000077    8c 46 ea         mov    WORD PTR [bp-22],es
  165.     *** 00007a    26 8b 07         mov    ax,WORD PTR es:[bx]
  166.     *** 00007d    26 8b 57 02         mov    dx,WORD PTR es:[bx+2]
  167.     *** 000081    8b f8             mov    di,ax
  168.     *** 000083    bb 38 00         mov    bx,OFFSET DGROUP:$SG275
  169.     *** 000086    8b f3             mov    si,bx
  170.     *** 000088    8c 5e fe         mov    WORD PTR [bp-2],ds    ;j
  171.     *** 00008b    80 3f 00         cmp    BYTE PTR [bx],0
  172.     *** 00008e    74 0b             je    $FB281
  173.     *** 000090    8e c2             mov    es,dx
  174.                     $F279:
  175. ;|***     if (*pos != *p_pos)
  176. ; Line 62
  177.     *** 000092    26 8a 05         mov    al,BYTE PTR es:[di]
  178.     *** 000095    38 04             cmp    BYTE PTR [si],al
  179.     *** 000097    74 73             je    $L313
  180.                     $L312:
  181.     *** 000099    16             push    ss
  182.     *** 00009a    1f             pop    ds
  183.     ASSUME DS: DGROUP
  184.                     $FB281:
  185.     *** 00009b    8e 46 fe         mov    es,WORD PTR [bp-2]    ;j
  186.     *** 00009e    26 80 3c 00         cmp    BYTE PTR es:[si],0
  187.     *** 0000a2    74 03             je    $JCC162
  188.     *** 0000a4    e9 c1 00         jmp    $FC277
  189.                     $JCC162:
  190. ;|***       break;
  191. ;|***       if (!*p_pos)
  192. ;|***     {        /* In this example this is allways true */
  193. ;|***       if (count++)
  194. ; Line 66
  195.     *** 0000a7    8b 46 ec         mov    ax,WORD PTR [bp-20]    ;count
  196.     *** 0000aa    ff 46 ec         inc    WORD PTR [bp-20]    ;count
  197.     *** 0000ad    0b c0             or    ax,ax
  198.     *** 0000af    74 79             je    $I284
  199. ;|***         {
  200. ;|***           register int j;
  201. ;|***           /* This loop will be garbage */
  202. ;|***           for (j=0 ; j < k_length ; j++)
  203. ; Line 70
  204.     *** 0000b1    33 ff             xor    di,di
  205.     *** 0000b3    89 7e fe         mov    WORD PTR [bp-2],di    ;j
  206.     *** 0000b6    39 7e f6         cmp    WORD PTR [bp-10],di    ;k_length
  207.     *** 0000b9    7e 5f             jle    $L303
  208.     *** 0000bb    c4 5e f0         les    bx,DWORD PTR [bp-16]    ;best_info
  209.     *** 0000be    26 8b 07         mov    ax,WORD PTR es:[bx]
  210.     *** 0000c1    26 8b 57 02         mov    dx,WORD PTR es:[bx+2]
  211.     *** 0000c5    89 46 e4         mov    WORD PTR [bp-28],ax
  212.     *** 0000c8    89 56 e6         mov    WORD PTR [bp-26],dx
  213.     *** 0000cb    8b f7             mov    si,di
  214.     *** 0000cd    8b 7e f4         mov    di,WORD PTR [bp-12]
  215.     *** 0000d0    8b cb             mov    cx,bx
  216.     *** 0000d2    8e 5e 08         mov    ds,WORD PTR [bp+8]
  217.     ASSUME DS: NOTHING
  218.                     $F286:
  219. ;|***         if (best_info->name[j] != dir_info->dir_entry[i].name[j])
  220. ; Line 71
  221. ; MONTY: LOOK AT THE FOLLOWING MESS (Without test_func() this is about 7 lines)
  222.     *** 0000d5    c4 5e e8         les    bx,DWORD PTR [bp-24]
  223.     *** 0000d8    26 c4 1f         les    bx,DWORD PTR es:[bx]
  224. ; MONTY: THIS CODE DOES NOTHING >>
  225.     *** 0000db    8b c3             mov    ax,bx
  226.     *** 0000dd    8c c2             mov    dx,es
  227.     *** 0000df    c4 5e e4         les    bx,DWORD PTR [bp-28]
  228.     *** 0000e2    8e c2             mov    es,dx
  229.     *** 0000e4    8b d8             mov    bx,ax
  230. ; MONTY: THIS CODE DOES NOTHING << (dx:bx is reset later)
  231.     *** 0000e6    89 5e e0         mov    WORD PTR [bp-32],bx
  232.     *** 0000e9    8c 46 e2         mov    WORD PTR [bp-30],es
  233.     *** 0000ec    c4 5e e4         les    bx,DWORD PTR [bp-28]
  234.     *** 0000ef    8b c3             mov    ax,bx
  235.     *** 0000f1    8c c2             mov    dx,es
  236.     *** 0000f3    c4 5e e0         les    bx,DWORD PTR [bp-32]
  237.     *** 0000f6    50             push    ax
  238.     *** 0000f7    26 8a 00         mov    al,BYTE PTR es:[bx][si]
  239.     *** 0000fa    58             pop    ax
  240.     *** 0000fb    8e c2             mov    es,dx
  241.     *** 0000fd    8b d8             mov    bx,ax
  242.     *** 0000ff    26 8a 00         mov    al,BYTE PTR es:[bx][si]
  243. ; MONTY: This should maybe be [bp-32], [bp-33] is definitely wrong 
  244.     *** 000102    38 46 df         cmp    BYTE PTR [bp-33],al
  245.     *** 000105    74 1b             je    $L310
  246.                     $L309:
  247.     *** 000107    16             push    ss
  248.     *** 000108    1f             pop    ds
  249.     ASSUME DS: DGROUP
  250.     *** 000109    eb 12             jmp    SHORT $FB288
  251.     *** 00010b    90             nop    
  252.                     $L313:
  253. ;|***        pos++,p_pos++)
  254. ; Line 61
  255.     *** 00010c    47             inc    di
  256.     *** 00010d    46             inc    si
  257.     *** 00010e    80 3c 00         cmp    BYTE PTR [si],0
  258.     *** 000111    74 03             je    $JCC27